<?php
App::uses('AppController', 'Controller');

class //nameClass//Controller extends AppController {

//uses//
    public $paginate = array(
            'limit' => 10 //order////conditions//
    );
    
	public function index() {
        $this->set('title_for_layout', "//controller_caption// Index");
        $this->//nameClass_Singularize//->recursive = 0;
		$this->set('//nameclass//', $this->paginate());        
	}
    
    public function add() {      
        $this->set('title_for_layout', "//controller_caption// Nuevo");
//textfield_reference//
		if ($this->request->is('post')) {
			$this->//nameClass_Singularize//->create();
			if ($this->//nameClass_Singularize//->save($this->request->data)) {
				//$this->Session->setFlash(__('The //nameClass_Singularize// has been saved'));
                $this->Session->setFlash(__('El //nameClass_Singularize// ha sido guardado'));
				$this->redirect(array('action' => 'index'));
			} else {
				//$this->Session->setFlash(__('The //nameClass_Singularize// could not be saved. Please, try again.'));
                $this->Session->setFlash(__('El //nameClass_Singularize// no se pudo guardar. Por favor, intente de nuevo.'));
			}
		}        
	}

	public function view($id = null) {
        $this->set('title_for_layout', "//controller_caption// Ver");
		$this->//nameClass_Singularize//->id = $id;
		if (!$this->//nameClass_Singularize//->exists()) {
			throw new NotFoundException(__('Invalid //nameClass_Singularize//'));
		}
		$this->set('//nameclass_singularize//', $this->//nameClass_Singularize//->read(null, $id));        
	}
    
	public function edit($id = null) {   
        $this->set('title_for_layout', "//controller_caption// Editar");
        //textfield_reference//
		$this->//nameClass_Singularize//->id = $id;
		if (!$this->//nameClass_Singularize//->exists()) {
			throw new NotFoundException(__('Invalid //nameClass_Singularize//'));
		}
		if ($this->request->is('post') || $this->request->is('put')) {
			if ($this->//nameClass_Singularize//->save($this->request->data)) {
				//$this->Session->setFlash(__('The //nameClass_Singularize// has been saved'));
                $this->Session->setFlash(__('El //nameClass_Singularize// ha sido guardado'));
				$this->redirect(array('action' => 'index'));
			} else {
				//$this->Session->setFlash(__('The //nameClass_Singularize// could not be saved. Please, try again.'));
                $this->Session->setFlash(__('El //nameClass_Singularize// no se pudo guardar. Por favor, intente de nuevo.'));
			}
		} else {
			$this->request->data = $this->//nameClass_Singularize//->read(null, $id);
		}        
	}

	public function delete($id = null) {
		if (!$this->request->is('post')) {
			throw new MethodNotAllowedException();
		}
		$this->//nameClass_Singularize//->id = $id;
		if (!$this->//nameClass_Singularize//->exists()) {
			throw new NotFoundException(__('Invalid //nameClass_Singularize//'));
		}
		if ($this->//nameClass_Singularize//->delete()) {
			$this->Session->setFlash(__('//nameClass_Singularize// deleted'));
			$this->redirect(array('action' => 'index'));
		}
		$this->Session->setFlash(__('//nameClass_Singularize// was not deleted'));
		$this->redirect(array('action' => 'index'));
	}
    
    //views_str//
}